package com.ruoyi.project.tool.swagger.UserController;

import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.ServletUtils;
import com.ruoyi.framework.security.LoginUser;
import com.ruoyi.framework.security.service.TokenService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.project.system.domain.SysAddress;
import com.ruoyi.project.system.service.ISysAddrService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/mobileUser/address")
public class AddressController extends BaseController {

    @Autowired
    private ISysAddrService addrService;


    @ApiOperation("获取用户地址列表")
    @GetMapping("/getList")
    public AjaxResult getList()
    {
        SysAddress address=new SysAddress();
        address.setUserId(SecurityUtils.getLoginUser().getUser().getUserId());
        return AjaxResult.success(addrService.selectAddrList(address));
    }

    @ApiOperation("添加用户地址")
    @PostMapping("/insertAddress")
    public AjaxResult insertAddress(@RequestBody SysAddress address)
    {
        address.setUserId(SecurityUtils.getLoginUser().getUser().getUserId());
        address.setCreateBy(SecurityUtils.getUsername());
        return AjaxResult.success(addrService.insertAddr(address));
    }

}
